package nxu.it.service;

import nxu.it.dao.JdbiFactory;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Singleton;


public class LoginService {
    public Boolean check(String username, String password) {
        if (username == null || password == null) {
            return false;
        }
        String sql = "SELECT count(*) FROM user WHERE `username` = :username AND `password` = :password";
        Long count = JdbiFactory.getJdbi().withHandle(handle -> handle.createQuery(sql)
                .bind("username",username)
                .bind("password",password)
                .mapTo(Long.class)
                .first());
        return count != null && count > 0;
    }
}

